/**
  EG4Sim project, Anyang Normal University && IMP-CAS
  \class EG4TOFW
  \brief the model of the TOF Wall
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2023-11-08
  \date 2023-11-08 last modified
  \copyright Copyright (c) 2023-2024 IMP-CAS with LGPLv3 LICENSE
*/

#include "EG4TOFW.h"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4VisAttributes.hh"
#include "G4PVPlacement.hh"
#include "G4VisAttributes.hh"
#include "G4SystemOfUnits.hh"
#include "G4NistManager.hh"

EG4TOFW::EG4TOFW() : EG4Det(){
  auto air = G4Material::GetMaterial("airLanzhou", true);
  // plastic scintillators for TOFWall (BICRON BC408)
  auto nist = G4NistManager::Instance();
  auto sci = nist->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");

  fLV = new G4LogicalVolume(new G4Box("TOFW", 680.*mm, 600.*mm, 20.*mm),
    air, "TOFW");
  // strips in TOFWall
  fStripLV = new G4LogicalVolume(new G4Box("TOFWStrip", 50.*mm, 600.*mm, 5.*mm),
    sci, "TOFWStrip");
  // milky light green
  fStripLV->SetVisAttributes(new G4VisAttributes(G4Colour(.8, .9, 1.)));

  for(int i = 0; i < kNS; i++){
    char name[128]{}; sprintf(name, "TOFWStrip%d", i);
    fStrip[i] = new G4PVPlacement(nullptr,
      G4ThreeVector((i-7)*90.*mm, 0., i%2 ? -15.*mm : 5.*mm),
      fStripLV, name, fLV, false, i, true);
  } // end for over strips
} // end ctor

EG4TOFW::~EG4TOFW(){}
